<?php
//require_once WEBROOT.'/lib/capcha/capcha.class.php';
use \lib\capcha\capcha;
$i=new capcha(4,4);
$i->draw_code();
return;
exit;
header('Content-type:image/png');
$h=imagecreatetruecolor(100,100);

$h=imagecreatefromjpeg(WEBROOT.'/static/img/verify/'.strval(rand(1,8)).'.jpg');
$str='qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
$code='';
for ($i=0;$i<4;$i++)
{
    $code.=$str{rand(0,strlen($str)-1)};
}
$_SESSION['code']=$code;
for($i=0;$i<4;$i++)
{
    $fontsize = rand(35,40);
    $fontcolor = imagecolorallocate($h, mt_rand(0, 120), mt_rand(0, 120), mt_rand(0, 120));
    $fontcontent = $code{$i};
    // 显示的坐标
    $x = ($i * 200 / 4) + mt_rand(5, 10)+$fontsize-30;
    $y = mt_rand(50, 80);
    // 填充内容到画布中
    imagefttext($h,$fontsize,rand(0,45),
        $x,$y,$fontcolor,
        WEBROOT.'/static/font/en/'.strval(rand(1,6)).'.ttf',
        $fontcontent);
}
for ($i = 0; $i < 10; $i++) {
    $linecolor = imagecolorallocate($h, mt_rand(50, 200), mt_rand(50, 200), mt_rand(50, 200));
    imageline($h, mt_rand(1, 199), mt_rand(1, 79), mt_rand(1, 99), mt_rand(1, 79), $linecolor);
}


//imagefill($h,0,0,0xff0000);     // 图片填充        2和3  为位置      3 为颜色   开头为0x；
//imageline($h,0,0,60,80,0x0000ff);       //划线
//imagestring($h,50,10,10,'hello php',0x0000ff);
//imagefttext($h,15,10,5,55,0x00ff00,WEBROOT.'/static/font/ch/1.ttf','你好 php');








imagepng($h);
imagedestroy($h);       //图片使用完关闭










